package com.ruoyi.ncpcs.controller;

import java.util.List;

import com.ruoyi.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.ncpcs.domain.NcpcsInterfaceFields;
import com.ruoyi.ncpcs.service.INcpcsInterfaceFieldsService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;

import javax.servlet.http.HttpServletResponse;

/**
 * interfaceFieldsManageController
 *
 * @author ruoyi
 * @date 2022-09-25
 */
@RestController
@RequestMapping("/ncpcs/upload/interfaceFields")
public class NcpcsInterfaceFieldsController extends BaseController {
    @Autowired
    private INcpcsInterfaceFieldsService ncpcsInterfaceFieldsService;

    /**
     * 查询interfaceFieldsManage列表
     */
    @RequiresPermissions("@ss.hasPermi('upload:interfaceFields:list')")
    @GetMapping("/list")
    public AjaxResult list(NcpcsInterfaceFields ncpcsInterfaceFields) {
        List<NcpcsInterfaceFields> list = ncpcsInterfaceFieldsService.selectNcpcsInterfaceFieldsList(ncpcsInterfaceFields);
        return AjaxResult.success(list);
    }

    /**
     * 导出interfaceFieldsManage列表
     */
    @RequiresPermissions("@ss.hasPermi('upload:interfaceFields:export')")
    @Log(title = "interfaceFieldsManage", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public void export(HttpServletResponse response, NcpcsInterfaceFields ncpcsInterfaceFields) {
        List<NcpcsInterfaceFields> list = ncpcsInterfaceFieldsService.selectNcpcsInterfaceFieldsList(ncpcsInterfaceFields);
        ExcelUtil<NcpcsInterfaceFields> util = new ExcelUtil<NcpcsInterfaceFields>(NcpcsInterfaceFields.class);
        util.exportExcel(response, list, "interfaceFieldsManage数据");
    }

    /**
     * 获取interfaceFieldsManage详细信息
     */
    @RequiresPermissions("@ss.hasPermi('upload:interfaceFields:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(ncpcsInterfaceFieldsService.selectNcpcsInterfaceFieldsByInterfaceId(id));
    }

    /**
     * 新增interfaceFieldsManage
     */
    @RequiresPermissions("@ss.hasPermi('upload:interfaceFields:add')")
    @Log(title = "interfaceFieldsManage", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NcpcsInterfaceFields ncpcsInterfaceFields) {
        return toAjax(ncpcsInterfaceFieldsService.insertNcpcsInterfaceFields(ncpcsInterfaceFields));
    }

    /**
     * 修改interfaceFieldsManage
     */
    @RequiresPermissions("@ss.hasPermi('upload:interfaceFields:edit')")
    @Log(title = "interfaceFieldsManage", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NcpcsInterfaceFields ncpcsInterfaceFields) {
        return toAjax(ncpcsInterfaceFieldsService.updateNcpcsInterfaceFields(ncpcsInterfaceFields));
    }

    /**
     * 删除interfaceFieldsManage
     */
    @RequiresPermissions("@ss.hasPermi('upload:interfaceFields:remove')")
    @Log(title = "interfaceFieldsManage", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(ncpcsInterfaceFieldsService.deleteNcpcsInterfaceFieldsByInterfaceIds(ids));
    }
}
